	(function($,window){
        window.editPassword = {};
        editPassword.S_level;
        editPassword._changCallback;
		editPassword._closeCallback;
        // 页面默认执行方法
        editPassword.init = function(){

        };

        //CharMode函数 
		//测试某个字符是属于哪一类. 
        editPassword.CharMode = function(iN){
        	if (iN >= 48 && iN <= 57) //数字 
				return 1;
			if (iN >= 65 && iN <= 90) //大写字母 
				return 2;
			if (iN >= 97 && iN <= 122) //小写 
				return 4;
			else
				return 8; //特殊字符 
        };

        //checkStrong函数 
		//返回密码的强度级别
        editPassword.checkStrong = function(sPW){
        	if (sPW.length <= 4)
				return 0; //密码太短 
			Modes = 0;
			for (var i = 0; i < sPW.length; i++) {
				//测试每一个字符的类别并统计一共有多少种模式. 
				Modes |= editPassword.CharMode(sPW.charCodeAt(i));
			}
			return editPassword.bitTotal(Modes);
        };

        //bitTotal函数 
		//计算出当前密码当中一共有多少种模式 
		editPassword.bitTotal = function(num){
			modes = 0;
			for (var i = 0; i < 4; i++) {
				if (num & 1)
					modes++;
				num >>>= 1;
			}
			return modes;
		};

		//pwStrength函数 
		//当用户放开键盘或密码输入框失去焦点时,根据不同的级别显示不同的颜色 
		editPassword.pwStrength = function(pwd) {
			O_color = "#eeeeee";
			L_color = "#FF0000";
			M_color = "#FF9900";
			H_color = "#33CC00";
			if (pwd == null || pwd == '') {
				Lcolor = Mcolor = Hcolor = O_color;
			}else{
				editPassword.S_level = editPassword.checkStrong(pwd);
				
				switch (editPassword.S_level) {
				case 0:
					Lcolor = Mcolor = Hcolor = O_color;
				case 1:
					Lcolor = L_color;
					Mcolor = Hcolor = O_color;
					break;
				case 2:
					Lcolor = Mcolor = M_color;
					Hcolor = O_color;
					break;
				default:
					Lcolor = Mcolor = Hcolor = H_color;
				}
			}

			document.getElementById("strength_L").style.background = Lcolor;
			document.getElementById("strength_M").style.background = Mcolor;
			document.getElementById("strength_H").style.background = Hcolor;
			return;
		};

		editPassword.showCryptDialog = function(callback,closeCallback){
			editPassword._changCallback=callback;
			editPassword._closeCallback=closeCallback;
			editPassword.resetCryptDialog();
		};

		// 重置修改密码弹框
		editPassword.resetCryptDialog = function(){
			$("#pwdOldCrypt").val("");
			$("#pwdNewCrypt").val("");
			$("#pwdCfmCrypt").val("");
			CommonPageScript.createDialog('edit_password');
			$("#edit_password").removeClass("displayNone").addClass("displayBlock");
			//去掉按Enter键事件
			document.onkeydown = "";
		};

		//关闭密码弹出框
		editPassword.changeClose = function(){
		    $("#pwdOldCrypt").val("");
		    $("#pwdNewCrypt").val("");
		    $("#pwdCfmCrypt").val("");
		    $('#edit_password').dialog('close');
		    editPassword.pwStrength();
		    $("#edit_password").removeClass("displayBlock").addClass("displayNone");
			if(editPassword._closeCallback){
				editPassword._closeCallback();
			}
		};

		// 更新密码
		editPassword.updateCrypt = function(){
		    var updateOpts = {
		    	type : "get",
	            url:editPasswordUrl.passwordValidate,
	            data:{
	            	oldPwd:$.trim($("#pwdOldCrypt").val())
	            },
	            callback:function(data){
	            	if(data.status == 0){
	            		return false;
	            	}else{
						editPassword.changeCrypt();
	            	}
	            },
	            messager:function(){}
	        };
	        Utils.doAjax(updateOpts);
	    };

	    // 密码强度提示
	    editPassword.changeCrypt = function(){
	    	if(editPassword.S_level<2){
		       $.messager.alert("提示", "密码强度不足,为保证安全请重新设置!", "info",function(){
			   		$("#pwdNewCrypt").val("");
					$("#pwdCfmCrypt").val("");
		       });
		       return;
	    	}

	    	// 验证新旧密码是否一致
		    if(!$("#formChangePwd").form("validate")){
		    	return;
		    }
		   
		   var changeOpts = {
		    	type : "get",
	            url:editPasswordUrl.updatePassword,
	            data:{
	            	newPwd:$.trim($("#pwdCfmCrypt").val())
	            },
	            callback:function(){				
					editPassword.closeCryptDialog();
	            },
	            messager:function(){}
	        };
	        Utils.doAjax(changeOpts);
	    };

	    // 是否重新登录
	    editPassword.closeCryptDialog = function(){
	    	editPassword.resetCryptDialog();
		    $("#edit_password").dialog("close");
			$.messager.confirm('确认','建议重新登录,是否立刻登录?',function(r){    
			    if(r){    
			    	CommonPageScript.loginOut();
			    }else{
			    	if(editPassword._changCallback){
				       editPassword._changCallback();
			    	}
			    }    
		    });
	    };

    })(jQuery,window);

	//扩展easyui验证方法   
	$.extend($.fn.validatebox.defaults.rules, {
		// 验证新旧密码是否一致
		notEquals:{
			validator : function(value, param) {
				return value != $(param[0]).val();
			},
			message : "新密码和旧密码必须不同!"
		},
		// 验证两次输入密码是否一致
		equals:{
			validator : function(value, param) {
				return value == $(param[0]).val();
			},
			message : "两次密码输入不一致!"
		}
	});
